package com.bawei.a2010douyin.base.interceptor;

import com.blankj.utilcode.util.SPUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

//token拦截器
public class TokenInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {//拦截器；添加请求头
        String token = SPUtils.getInstance().getString("token");//获得登陆成功后存储的token
        Request request = chain.request().newBuilder().addHeader("token", token).build();//添加token请求头
        return chain.proceed(request);
    }
}
